package com.nn.controller;

import com.nn.pojo.DomesticTravel;
import com.nn.service.DomesticTravelService;
import com.nn.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 境内旅游层代码
 */
@RestController
@CrossOrigin
@RequestMapping("/domesticTravel")
public class DomesticTravelController {
    @Autowired
    private DomesticTravelService domesticTravelService;

    /*
     * await this.$http.get("/domesticTravel/finddomesticTravelList/3")
     * 请求类型:GET
     * 请求参数:id
     * URL:
     * 返回值类型:SysResult对象*/
    @GetMapping("/finddomesticTravelList/{level}")
    public SysResult finddomesticTravelList(@PathVariable Integer level) {
        List<DomesticTravel> domesticTravelList = domesticTravelService.finddomesticTravelList(level);
        return SysResult.success(domesticTravelList);
    }

    /*
     * await this.$http.put(`/domesticTravel/status/${domesticTravel.id}/${domesticTravel.status}`)
     * 请求类型:PUT
     * 请求参数:domesticTravel
     * URL:
     * 返回值类型:SysResult对象*/
    @PutMapping("/status/{id}/{status}")
    public SysResult updateStatus(DomesticTravel domesticTravel) {
        domesticTravelService.updateStatus(domesticTravel);
        return SysResult.success();
    }

    /*
     * await this.$http.post("/domesticTravel/savedomesticTravel", this.domesticTravelForm)
     * http://localhost:8091/domesticTravel/savedomesticTravel
     * 请求类型:POST
     * 请求参数:domesticTravel表单
     * 返回值类型:SysResult对象
     * */
    @PostMapping("/savedomesticTravel")
    public SysResult adddomesticTravelForm(@RequestBody DomesticTravel domesticTravel) {
        domesticTravelService.adddomesticTravelForm(domesticTravel);
        return SysResult.success();
    }

    /*
     * await this.$http.put('/domesticTravel/updatedomesticTravel', this.updatedomesticTravelForm)
     * 请求参数:*/
    @PutMapping("/updatedomesticTravel")
    public SysResult updatedomesticTravel(@RequestBody DomesticTravel domesticTravel) {
        domesticTravelService.updatedomesticTravel(domesticTravel);
        return SysResult.success();
    }

    /*await this.$http.delete("/domesticTravel/deletedomesticTravel"*/
    @DeleteMapping("/deletedomesticTravel")
    public SysResult deletedomesticTravel(DomesticTravel domesticTravel) {
        domesticTravelService.deletedomesticTravel(domesticTravel);
        return SysResult.success();
    }
}
